package com.lz.gmall.product.controller;

import com.lz.gmall.common.result.Result;
import com.lz.gmall.common.result.ResultCodeEnum;
import com.lz.gmall.product.entity.BaseCategory3;
import com.lz.gmall.product.service.BaseCategory3Service;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
@Api(tags = "三级产品")
public class BaseCategory3Controller {

    @Autowired
    private BaseCategory3Service baseCategory3Service;

    /**
     * 根据二级产品id获取三级产品
     * @param cate2Id 二级产品id
     * @return 三级产品集合
     */
    @GetMapping("/getCategory3/{category2Id}")
    @ApiOperation("获取产品的三级分类")
    public Result<List<BaseCategory3>> findAll(@PathVariable("category2Id") Long cate2Id){
        List<BaseCategory3> list = baseCategory3Service.findAllByCate2Id(cate2Id);
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }
}
